home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / getCopyAnimCurveCommands.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.8 KB  |  136 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  July 20, 1999
  22. //  Author:         mm
  23. //
  24. //    Procedure Name:
  25. //        getCopyAnimCurveCommands
  26. //
  27. //    Description:
  28. //        This is a helper proc which will return a string array of
  29. //    the commands necessary to copy an animCurve
  30. //
  31. //  Input Arguments:
  32. //        string $animCurve        The name of the object
  33. //
  34. //  Return Value:
  35. //      string array of commands to create a copy of the animCurve
  36. //
  37.  
  38. global proc string[]
  39. getCopyAnimCurveCommands (string $animCurve)
  40. {
  41.     string $commands[];
  42.     int $entry = 0;
  43.  
  44.     // Make sure we are trying to copy an animCurve
  45.     //
  46.     if (!isAnimCurve ($animCurve)) {
  47.         return ($commands);
  48.     }
  49.  
  50.     // Set the proper units
  51.     //
  52.     string $angleUnits = `currentUnit -query -angle`;
  53.     string $linearUnits = `currentUnit -query -linear`;
  54.     string $timeUnits = `currentUnit -query -time`;
  55.     $commands[$entry++] = "string $angleUnits = `currentUnit -query -angle`;";
  56.     $commands[$entry++] = "string $linearUnits = `currentUnit -query -linear`;";
  57.     $commands[$entry++] = "string $timeUnits = `currentUnit -query -time`;";
  58.     $commands[$entry++] = (
  59.         "currentUnit -angle " + $angleUnits +
  60.         " -linear " + $linearUnits +
  61.         " -time " + $timeUnits +
  62.         ";"
  63.     );
  64.  
  65.     // Create the animCurve
  66.     //
  67.     $commands[$entry++] = ("string $animCurve = `createNode " + `nodeType $animCurve` + "`;");
  68.  
  69.     // Set weighted/unweighted tangents
  70.     //
  71.     int $weightedTangents[] = `keyTangent -query -weightedTangents $animCurve`;
  72.     $commands[$entry++] = ("keyTangent -edit -weightedTangents " + $weightedTangents[0] + ";");
  73.  
  74.     // Set infinity types
  75.     //
  76.     int $infinity = `getAttr ($animCurve + ".preInfinity")`;
  77.     $commands[$entry++] = ("setAttr ($animCurve + \".preInfinity\") " + $infinity + ";");
  78.     $infinity = `getAttr ($animCurve + ".postInfinity")`;
  79.     $commands[$entry++] = ("setAttr ($animCurve + \".postInfinity\") " + $infinity + ";");
  80.  
  81.     // Set each of the keys
  82.     //
  83.     int $numKeys = `keyframe -query -keyframeCount $animCurve`;
  84.     float $time[] = `keyframe -query -timeChange $animCurve`;
  85.     float $value[] = `keyframe -query -valueChange $animCurve`;
  86.     int $breakdown[] = `keyframe -query -breakdown $animCurve`;
  87.     string $inTangentType[] = `keyTangent -query -inTangentType $animCurve`;
  88.     string $outTangentType[] = `keyTangent -query -outTangentType $animCurve`;
  89.     int $lock[] = `keyTangent -query -lock $animCurve`;
  90.     int $weightLock[] = `keyTangent -query -weightLock $animCurve`;
  91.     for ($key = 0; $key < $numKeys; $key++) {
  92.         $commands[$entry++] = (
  93.             "setKeyframe -time " + $time[$key] +
  94.             " -value " + $value[$key] +
  95.             " -breakdown " + $breakdown[$key] +
  96.             ($inTangentType[$key] == "fixed" ? "" : " -inTangentType " + $inTangentType[$key]) +
  97.             ($outTangentType[$key] == "fixed" ? "" : " -outTangentType " + $outTangentType[$key]) +
  98.             " $animCurve;"
  99.         );
  100.         if ($inTangentType[$key] == "fixed") {
  101.             float $inAngle[] = `keyTangent -index $key -query -inAngle $animCurve`;
  102.             float $inWeight[] = `keyTangent -index $key -query -inWeight $animCurve`;
  103.             $commands[$entry++] = (
  104.                 "keyTangent -edit -index " + $key +
  105.                 " -inTangentType fixed" +
  106.                 " -inAngle " + $inAngle[0] +
  107.                 " -inWeight " + $inWeight[0] +
  108.                 " $animCurve;"
  109.             );
  110.         }
  111.         if ($outTangentType[$key] == "fixed") {
  112.             float $outAngle[] = `keyTangent -index $key -query -outAngle $animCurve`;
  113.             float $outWeight[] = `keyTangent -index $key -query -outWeight $animCurve`;
  114.             $commands[$entry++] = (
  115.                 "keyTangent -edit -index " + $key +
  116.                 " -outTangentType fixed" +
  117.                 " -outAngle " + $outAngle[0] +
  118.                 " -outWeight " + $outWeight[0] +
  119.                 " $animCurve;"
  120.             );
  121.         }
  122.         $commands[$entry++] = (
  123.             "keyTangent -edit -index " + $key +
  124.             " -lock " + $lock[$key] +
  125.             ($weightedTangents[0] ? " -weightLock " + $weightLock[$key] : "") +
  126.             " $animCurve;"
  127.         );
  128.     }
  129.  
  130.     // Restore the original units
  131.     //
  132.     $commands[$entry++] = "currentUnit -angle $angleUnits -linear $linearUnits -time $timeUnits;";
  133.  
  134.     return ($commands);
  135. }
  136.